<?php
/**
 * Created by PhpStorm.
 * User: Kiriti
 * Date: 2016/4/1 0001
 * Time: 14:57
 */

namespace app\controllers;
use Yii;

use yii\web\Controller;
use yii\helpers\Html;

class RegisterController extends Controller
{
    public $layout= "main2";
    public function actionShow(){
        if(!empty($_COOKIE['user_id'])){

            RegisterController::prepare();
            $this->redirect(["index/show"]);

        }
        return $this->render('register.php');

    }



    public function prepare(){
        if(!empty($_COOKIE['user_id'])) {
            $user_id = $_COOKIE['user_id'];
            $user = UsercenterController::getUserInfo($user_id);

            $view = Yii::$app->view;
            $view->params['title'] = "个人资料";
            PrlikeController::setView($user);
        }
    }
    public function actionValiphone($phone){
        $phoneDb = User::find()->where(['mobile'=>$phone])->one();
        if($phoneDb == null)
            echo "此手机号可以注册";
        else{
            echo "<script>alert('此手机号已经存在')</script>";
        }
    }

    public function validpswd($phone){
        $phoneDb = User::find()->where(['mobile'=>$phone])->one();
        if($phoneDb == null)
            echo "此手机号可以注册";
        else{
            echo "<script>alert('此手机号已经存在')</script>";
        }
    }
}